<?php
$title = 'Драконы';
include_once '../inc/fnc.php';
if(isset($_GET['submit'])){
    $oldPwd = trim(htmlspecialchars($_POST['oldPwd']));
    $newPwd = trim(htmlspecialchars($_POST['newPwd']));
    $newPwd1 = trim(htmlspecialchars($_POST['newPwd1']));
if($user['password'] != $oldPwd){
    $_SESSION['error'] ='<div class="plate_err mtb5 mlr10">
<div class="plate_err_b">
<div class="plate_err_l">
<div class="plate_err_r">
<div class="plate_err_rt">
<div class="plate_err_rb">
<div class="plate_err_lt">
<div class="plate_err_lb cntr">
Введённый пароль не соответсвует вашему!
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>';
header('location:./password');
exit;
}else{
    if($newPwd != $newPwd1){
            $_SESSION['error'] ='<div class="plate_err mtb5 mlr10">
<div class="plate_err_b">
<div class="plate_err_l">
<div class="plate_err_r">
<div class="plate_err_rt">
<div class="plate_err_rb">
<div class="plate_err_lt">
<div class="plate_err_lb cntr">
Поля пароль и повтор пароля должны совпадать
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>';
header('location:./password');
exit;
        
    }
    if($user['password'] == $oldPwd && $newPwd == $newPwd1){
        $db->query('UPDATE `users` SET `password`=? WHERE `id`=?',array($newPwd,$user['id']));
        $_SESSION['password'] =& $newPwd;
        
        header("Location:../profile");
        exit;
    }
}
    
}
?>
<div class="plate_nor mtb5 mlr10">
<div class="plate_nor_b">
<div class="plate_nor_l">
<div class="plate_nor_r">
<div class="plate_nor_rt">
<div class="plate_nor_rb">
<div class="plate_nor_lt">
<div class="plate_nor_lb cntr normal">
<div class="h1 major mt10"><span>Изменить Пароль</span></div>
<form class="cntr" id="id13" method="post" action="./password?submit"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="id13_hf_0" id="id13_hf_0"></div>
<label>Старый пароль:</label><br>
<input type="password" class="cntr" value="" name="oldPwd"><br>
<label>Новый пароль:</label><br>
<input type="password" class="cntr" value="" name="newPwd"><br>
<label>Повтор нового пароля:</label><br>
<input type="password" class="cntr" value="" name="newPwd1"><br>
<div>
<span class="btn_g w100 mt10"><span class="btn_g_in"><input type="submit" value="Изменить"></span></span>
<div class="clr"></div>
</div>
</form>

</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="hr mt15"></div>
<div class="ml10 mt5">
<img src="/images/back_16.png" width="16" height="16" alt=""> <a class="info" href="../cfg">Настройки</a>
</div>
<div class="hr mt10"></div>
<?php
include_once '../inc/foot.php';
